EXEC
Section: MINTLIB LIBRARY FUNCTIONS
(3)
Updated: 3 March 1993
Index
Return to Main Contents
NAME
execl, execv, execle, execlp, execve, execvp - execute a file
SYNOPSIS
#include <unistd.h>
int execl(char *path, ...);
int execv(char *path, char *argv[]);
int execle(char *path, ...);
int execlp(char *file, ...);
int execve(char *path, char *argv[], char *envp[]);
int execvp(char *file, char *argv[]);
DESCRIPTION
These routines transform the calling process into a new process.
The program indicated by `path' or `file' is loaded, then run.
There can be no return from a succesful exec call.
These calls differ in the following ways:
- execl, execle and execlp are called when the number of
arguments is known in advance, whereas execv, execve
and execvp take an argument vector.
- execl, execv, execle and execve are called with the full
path name of the program to be run, whereas execlp and
execvp are called with a filename that is searched on
the user's search path and that may be extended with
the filename extensions ".ttp", ".tos" and ".prg".
- execl, execv, execlp and execvp pass the parent's
environment to the new process, whereas execle and
execve take a pointer to an environment vector as
their final argument.
The last argument to the execl, execle and execlp functions
should be a NULL pointer.
An argument vector argv as used in execv, execve and execvp
is a pointer to a null-terminated array of character pointers
to null-terminated character strings. These strings constitute
the argument list to be made available to the new process.
By convention, at least one argument must be present in this
array, and the first element of this array should be the name
of the executed program. For execv and execve this is the last
component of the path argument; for execvp this is the file
argument.
The environment vector envp as used in execle and execve is also
a pointer to a null-terminated array of character pointers to
null-terminated strings. These strings pass information to the
new process which are not directly arguments to the command.
If envp is NULL, a copy of the parent process' environment is
passed.
Signals set to the default action (SIG_DFL) in the calling
process image are set to the default action in the new process.
Signals set to be ignored (SIG_IGN) by the calling process are
ignored by the new process. Signals set to be caught by the
calling process are reset to the default action in the new
process. Signals set to be blocked in the calling process remain
blocked in the new process, regardless of changes to the signal
action.
RETURN VALUES
These functions returns to the calling process only on failure,
for instance if the program called could not be found, if it
was not executable, or if not enough memory was available, in
which case -1 is returned and errno is set to indicate the error.
EXAMPLES
This will execute the program /bin/date or fail:
execl("/bin/date", "date", NULL);
This will search the program sh and then execute it;
it will fail only if sh, sh.tos, sh.ttp and sh.prg
could not be found:
execlp("sh", "sh", "-c", commandline, NULL);
This will call /bin/test using an already constructed
argument vector and an already constructed environment
vector, and fail if /bin/test could not be found:
execve("/bin/test", my_argv, my_envp);
SEE ALSO
fork(3),
signal(3),
tfork(3),
vfork(3),
_spawnve(3)
NOTES
When MiNT is not active, these library calls call a child
process and then _exit after the child has finished;
only when MiNT is active, the current process is truly
transformed into a new one.
On Un*x, execve is a system call, while the rest of these
calls are library routines. Under MiNT, it's all done in
the library.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- RETURN VALUES
-
- EXAMPLES
-
- SEE ALSO
-
- NOTES
-
This document was created by
man2html,
using the manual pages.
Time: 11:14:37 GMT, June 22, 2025